export default {
  namespaced: true,
  state: {
    count: 1,
    list: []
  },
  getters: {
    doubleCount(state, getters, rootState) {
      console.log(state, getters, rootState);
      return state.count * 2;
    }
  },
  mutations: {
    saveList(state, list) {
      state.list = list;
    },
    modifyCount(state, val) {
      state.count = val;
    },
    // eslint-disable-next-line no-unused-vars
    someMutation(state) {
      // todo
    }
  },
  actions: {
    getList(context, payload) {
      console.log('=context', context, payload);
      const { commit } = context;
      const list = [1, 3, 4];
      commit('saveList', list);
    },
    actionA({ commit }) {
      // eslint-disable-next-line no-unused-vars
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          commit('someMutation');
          resolve();
        }, 1000);
      });
    }
  }
};
